Skip to content

fix(server): stopping a preview server no longer depends on the test worker's pid - #139

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
fix/port-scanner-server-pid
Nov 17, 2026
Merged

ScriptedAlchemy merged 1 commit into
mainfrom
fix/port-scanner-server-pid

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

PortScanner.test.ts > rechecks the socket owner before stopping a Linux server without lsof failed intermittently in CI (seen on #137) with shared-group. The stop path compared the test's fake process table against the real process.pid. Whenever the test worker got pid 5000, one of the fixture pids, the target looked like the server itself and stop refused it.

Fix: the server pid is now an injected HostProcess.ProcessId reference next to HostProcess.Platform. It defaults to process.pid, so production behaviour is unchanged. The fake-table tests (layerProbeFailure and the agent-thread stop test, which previously built its table from the real process.pid) now provide a fixed SERVER_PID. The live test that uses real processes still reads the real pid.

Proof (vp test run src/preview/PortScanner.test.ts, with Object.defineProperty(process, "pid", { value: 5000 }) added temporarily to the test file):

  • base: × rechecks the socket owner before stopping a Linux server without lsof, the same shared-group error as CI
  • this branch: that test passes, with the pid pinned and with the real pid

The live test stops an agent's server through its job's group, and only a listed server also fails on this macOS host on unmodified base (stops is empty). It doesn't touch the pid and is unrelated to this change. It passes on Linux CI.

Other process.pid comparisons (ProcessDiagnostics, ResourceTelemetry) already derive their fixtures from process.pid in their tests, so they don't have this collision.

Done by Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

…worker's pid

The stop path compared the fake process table in PortScanner tests against
the real process.pid, so a test failed with shared-group whenever the worker
was assigned one of the fixture pids. The server pid is now read from
HostProcess.ProcessId, which defaults to process.pid, and tests with a fake
table provide a fixed one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f3bb666

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy ScriptedAlchemy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second-pass review of f3bb666: no code blocker found. The injected HostProcess.ProcessId defaults to process.pid in production, the fake process-table tests provide SERVER_PID = 100, and the real-process test retains the real PID. All 31 PortScanner tests passed locally, including the real Linux process/group-stop case.

I also checked the combined tree with the fixed #141: it merges cleanly and preserves both the PID injection and the macOS parser/fixture changes.

Full CI is the remaining validation gap. At this review, completed Fork CI jobs are passing, but Server tests 2, 3, 6, 7 and 8 are still queued in run 44010268629. I am holding the merge until that run completes successfully.

@ScriptedAlchemy
ScriptedAlchemy merged commit ce2d3a8 into main Nov 17, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant